<?php
class ViewHistoryUtil
{
    public function getRecentViewHistory($num,$fields=array(),$cache=0)
	{
		$list	= C('ViewHistoryService')->getRecentViewHistory($num,'num_id');
		return $this->getProductList($list,$fields,$cache);
	}
	
	public function getRecentClickHistory($num,$fields=array(),$cache=0)
	{
		$list	= C('ViewHistoryService')->getRecentClickHistory($num,'num_id');
		return $this->getProductList($list,$fields,$cache);
	}
	
	public function getRecentBuyHistory($num,$fields=array(),$cache=0)
	{
		$list	= C('ViewHistoryService')->getRecentBuyHistory($num,'num_id');
		return $this->getProductList($list,$fields,$cache);
	}
	
	public function getHotViewHistory($num,$fields=array(),$cache=0)
	{
		$list	= C('ViewHistoryService')->getHotViewHistory($num,'num_id');
		return $this->getProductList($list,$fields,$cache);
	}
	
	public function getHotClickHistory($num,$fields=array(),$cache=0)
	{
		$list	= C('ViewHistoryService')->getHotClickHistory($num,'num_id');
		return $this->getProductList($list,$fields,$cache);
	}
	
	public function getHotBuyHistory($num,$fields=array(),$cache=0)
	{
		$list	= C('ViewHistoryService')->getHotBuyHistory($num,'num_id');
		return $this->getProductList($list,$fields,$cache);
	}
	
	public function getProductList($list,$fields,$cache)
	{
		if(empty($list) || empty($list['rows']))
		{
			return false;
		}
		
		//获取商品
		$tmp	= array();
		foreach($list['rows'] as $lv)
		{
			$tmp[]	= $lv['num_id'];
		}
		$ids	= implode(',',$tmp);
		return C('ProductService')->getList(array('ids'=>$ids),$fields,$cache,'view_history');
	}
}
?>